all: clean library client server

VPATH = include
.PHONY = clean
FLAGS = -Wall
INTERFACE = library/MyInterface
NETWORK = library/MyNetwork
SERVERCORE = library/MyServerCore
LIB = -Iinclude -Llibrary -lpthread -lMyNetwork

client: client.c
	gcc $(FLAGS) -o bin/client client.c  $(LIB) -lpanel -lncurses -lMyInterface

server: server.c
	gcc $(FLAGS) -o bin/server server.c  $(LIB) -lMyServerCore

library: network interface servercore

network: $(NETWORK)/network.c
	gcc -c $(NETWORK)/network.c -o $(NETWORK)/network.o
	ar rc library/libMyNetwork.a $(NETWORK)/*.o
	ranlib library/libMyNetwork.a

interface: $(INTERFACE)/interface.c
	gcc -c $(INTERFACE)/interface.c  -o $(INTERFACE)/interface.o -Iinclude
	ar rc library/libMyInterface.a $(INTERFACE)/*.o 
	ranlib library/libMyInterface.a
	
servercore: $(SERVERCORE)/lobby.c $(SERVERCORE)/reserve.c 
	gcc -c $(SERVERCORE)/lobby.c  -o $(SERVERCORE)/lobby.o -Iinclude
	gcc -c $(SERVERCORE)/reserve.c  -o $(SERVERCORE)/reserve.o -Iinclude
	ar rc library/libMyServerCore.a $(SERVERCORE)/*.o
	ranlib library/libMyServerCore.a

clean:
	rm -rf library/*.o
	rm -rf library/*~
	rm -rf library/*.a	
	rm -f include/*~
	rm -f bin/*
	rm -rf *~
